package com.liuchuanzheng.lcz_wanandroid.module.empty.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.liuchuanzheng.lcz_wanandroid.R
import com.liuchuanzheng.lcz_wanandroid.base.BaseFragment
import com.liuchuanzheng.lcz_wanandroid.databinding.FragmentEmptyBinding
import com.liuchuanzheng.lcz_wanandroid.databinding.FragmentHomeBinding
import com.liuchuanzheng.lcz_wanandroid.module.common.adapter.SimpleFragmentPagerAdapter
import com.liuchuanzheng.lcz_wanandroid.module.home.fragment.ArticleFragment

/**
 * @author 刘传政
 * @date 2021/9/14 0014 17:24
 * QQ:1052374416
 * 电话:18501231486
 * 作用:空的fragment，开发时经常先拿来占位
 * 注意事项:
 */
private const val ARG_PARAM1 = "param1"
class EmptyFragment:BaseFragment() {
    companion object {
        /**
         * Use this factory method to create a new instance of
         * this fragment using the provided parameters.
         *
         * @param param1 Parameter 1.
         * @return A new instance of fragment BlankFragment.
         */
        @JvmStatic
        fun newInstance(param1: String) =
            EmptyFragment().apply {
                arguments = Bundle().apply {
                    putString(ARG_PARAM1, param1)
                }
            }
    }
    private var param1: String? = null
    lateinit var mViewBinding: FragmentEmptyBinding
    /**
     * 当页面可见的时候，才加载当前页面。 没有打开的页面，就不会预加载。
     *
     *
     * 说白了，懒加载就是可见的时候才去请求数据。
     * 只回调一次
     */
    override fun onLazyLoad() {

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
            param1 = it.getString(ARG_PARAM1)
        }
    }

    /**
     * 因为系统自带的设置view方法有很多种,id,view都可以.所以这里不像
     * 大家都用id的封装方式,那是限制了自己
     * @param inflater
     * @param container
     */
    override fun creatView(inflater: LayoutInflater?, container: ViewGroup?): View {
        mViewBinding = FragmentEmptyBinding.inflate(inflater!!, container, false)
        return mViewBinding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mViewBinding.tvName.text = param1
    }
}